#include "blisp.h"

Type Number_t; /* location of Number type object */

Object *Number_new(int n)
{
	Object *o = GC_NEW_ATOMIC(Object);
	settype(o, TNUMBER);
	setnumber(o, n);
	return o;
}

SELF_EVAL_FUNC(Number)

const char *Number_to_cstr(Object *o)
{
	char buffer[16]; /* longest integer can't be longer than 10 digits + sign */
	sprintf(buffer, "%d", getnumber(o));
	return (const char *) GC_STRDUP(buffer);
}

Object *Number_equal(Object *o1, Object *o2)
{
	return cbool_to_lbool(number_equal(o1, o2));
}

int number_equal(Object *o1, Object *o2)
{
	return getnumber(o1) == getnumber(o2);
}

/* Basic math functions factories */
MATH2_FUNC(add)
MATH2_FUNC(sub)
MATH2_FUNC(mult)
MATH2_FUNC(div)
MATH2_FUNC(mod)
